6296: pick the first usable Location in a spatial array, not first truthy - #925
Merged
Conversation
…uthy _unwrap_location() picked the first truthy element of a spatial Location array, which is wrong when that element is a Location with no usable geometry (e.g. prefLabel-only). A later element with a real bbox/geometry/ centroid was silently dropped, so translated_spatial depended on element order in the source feed rather than which element actually had geometry. Closes GSA/data.gov#6296
cody-seibert-gsa
temporarily deployed
to
development
September 8, 2026 21:34 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 8, 2026 22:12 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 8, 2026 22:12 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 9, 2026 19:48 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 9, 2026 19:48 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 13:48 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 13:48 — with
GitHub Actions
Inactive
rshewitt
reviewed
Sep 10, 2026
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 14:21 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 14:21 — with
GitHub Actions
Inactive
_unwrap_location discarded a Location's prefLabel outright when no geometry/bbox/centroid was present, so a named place like "Nebraska" never reached the existing get_geo_from_string locations-table lookup in translate_spatial and always resolved to "". Real geometry anywhere in the input still wins; the prefLabel is only used as a fallback when nothing in the whole input has usable geometry.
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 15:26 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 15:26 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 15:37 — with
GitHub Actions
Inactive
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 15:37 — with
GitHub Actions
Inactive
rshewitt
reviewed
Sep 10, 2026
test_translate_spatial_location_array_skips_unusable_leading_element used the same input and primary assertion as test_translate_spatial_location_array_geometry_after_pref_label_skips_lookup, which also asserts the locations-table lookup is never attempted - strictly more coverage of the same case. Per rshewitt's review comment.
…ov-harvester into fix-spatial-array-first-usable
cody-seibert-gsa
temporarily deployed
to
development
September 10, 2026 16:18 — with
GitHub Actions
Inactive
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_unwrap_location()selected the first truthy element of aspatialLocation array, not the first usable one. A non-empty dict with no geometry (e.g. aprefLabel-only Location) is just as truthy as one with abbox, so[{prefLabel-only}, {bbox-bearing}]resolved toNULLwhile the reverse order worked fine - whether the record kept its geometry depended on element order in the source feed, not on which element actually had any.What changed
_unwrap_locationinto_unwrap_single_location(the existing single-Location logic, unchanged) plus a list loop that returns the first element_unwrap_single_locationresolves to something truthy, instead of picking the first truthy raw element up front.Closes GSA/data.gov#6296